from base.api import BaseApi
from account.controllers import message as message_ctl


class CreateMessageApi(BaseApi):

    need_params = {
        'name': ('角色名', 'required str'),
        'typ': ('角色名', 'required str'),
        'content': ('消息内容', 'required str'),
    }
    def post(self, request, params):
        message_ctl.create_message(**params)


class ListMessageApi(BaseApi):

    need_params = {
        'master_id': ('主账号', 'optional str'),
        'zone': ('分区', 'optional int'),
        'name': ('名称', 'optional str'),
        'typ': ('类型', 'optional str'),
        'page_num': ('页码', 'optional int'),
        'page_size': ('页容量', 'optional int'),
    }
    def get(self, request, params):
        data = message_ctl.get_messages(**params)
        return data
